//
//  YHYAVPlayer.m
//  YHYRealx
//
//  Created by yanghuiyan on 16/4/21.
//  Copyright © 2016年 yanghuiyan. All rights reserved.
//

#import "YHYAVPlayer.h"

@implementation YHYAVPlayer

+ (instancetype)shareYHYAVPlayer {
    
    static YHYAVPlayer *player = nil;
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        
        player = [[YHYAVPlayer alloc] init];
        
    });
    
    return player;
    
}

- (void)playWithURL:(NSString *)URL {
    
    if (self.currentItem) {
        [self replaceCurrentItemWithPlayerItem:self.currentItem];
    }
    
    AVPlayerItem *playItem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:URL]];
    
    [self replaceCurrentItemWithPlayerItem:playItem];
    
    [self play];
    
}


@end
